/*
=============================================
 Author:
 Student id:
 Description:
 Date:
=============================================
*/
#include <stdio.h>
void task11(void) {
  printf("\n Output of task11:\n");

  int x = 50, y = 25;
  int temp1, temp2;
  temp1 = x / ++y;
  printf("temp1= %d\ty= %d\n", temp1, y);
  y = 25;
  temp2 = x / y++;
  printf("temp2= %7d\ty= %d\n", temp2, y);

  /*
Output of
(1)	%7d:
(2)	%-7d:
Explanation: %7d pads the number with spaces on the left to make the total width
7 characters (right-aligned).
             %-7d pads the number with spaces on the right (left-aligned).
*/
}

void task12(void) {
  printf("\n Output of task12:\n");
  int i = 10, j = 5;
  float x = 5.0, y;
  y = x / i;
  // y = j / i;
  // y = (float)j / i;
}

void task13(void) {
  printf("\n Output of task13:\n");

  int m, n;

  // Prompt for input
  printf("Enter two integers (m and n, where n is not zero): ");
  scanf("%d %d", &m, &n);

  // Check if n is zero and reprompt if necessary
  while (n == 0) {
    printf("Error: n cannot be zero. Please enter a non-zero value for n: ");
    scanf("%d", &n);
  }

  // Calculate integer division
  int integer_result = m / n;

  // Calculate float division
  float float_result = (float)m / n;

  // Round to two decimal places manually
  float_result = (int)(float_result * 100 + 0.5) / 100.0;

  // Output results
  printf("Integer: %d divided by %d is %d\n", m, n, integer_result);
  printf("Float: %d divided by %d is %.2f\n", m, n, float_result);
}

int main() {
  task11();
  task12();
  task13();
  return 0;
}